import * as dictionariesData from '@/constants/data'

type DictionariesType = typeof dictionariesData

/** 通过code编码查询字典对应项 */
function useDictionaries() {
  /**type: 字典类型 code：字典对应的编码 */
  return (type: keyof DictionariesType, code: string) => {
    if (!dictionariesData[type]) { return }
    const result = dictionariesData[type].find(item => item.value === code)
    return result?.label
  }
}

export default useDictionaries